<?php

/*
 * Handle AJAX login.
 *
 */
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) and $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
	if (isset($_SESSION['login'])) {
		echo 'OK';
	}
	return;
} 

elseif (isset($_SESSION['login'])) {
	if (isset($_REQUEST['page'])) {
		header("Location: {$_REQUEST['page']}");
	} else {
		header("Location: /admin/");
	}
	return;
}

$smarty->display('login.tpl.html');
